Package gri.tasks.gui

Source Code of gri.tasks.gui.TaskInfo

/*
* File: TaskInfo.java
* Author: Daniel Rogers
* Created on Apr 15, 2008
*
*/
package gri.tasks.gui;

import gri.tasks.TaskDef;

import gri.tasks.managers.JobManager;
import gri.tasks.managers.TaskDescription;
import gri.tasks.managers.JobManagerTask;

/**
* Object describing a task in a JobManager.  This is similar to
* a TaskEntry, but it does not provide access to the task itself
* (as this is expected to be invoked through the manager). 
*
* TaskDescription and Definition are cached after first access.
*/
public class TaskInfo {

  JobManager jobManager;
  String taskId;

  TaskDescription taskDesc;
  TaskDef taskDef;

  // ---------------------------------------------------- Constructors

  public TaskInfo(JobManager jobManager, String taskId, TaskDescription taskDesc) {
    this.jobManager = jobManager;
    this.taskId = taskId;
    this.taskDesc = taskDesc;
  }
  public TaskInfo(JobManager jobManager, String taskId) {
    this(jobManager, taskId, null);
  }

  // ------------------------------------------------------- Accessors


  public JobManager getJobManager()    {return jobManager;}
  public String getTaskId()        {return taskId;}

  public TaskDescription getTaskDescription()  {
    if (taskDesc == null)
      taskDesc = jobManager.getTaskDescription(taskId);
    return taskDesc;
  }

  public TaskDef getTaskDefinition() {
    if (taskDef == null)
      taskDef = jobManager.getTaskDefinition(taskId);
    return taskDef;
  }
 
  /**
   * Returns a JobManagerTask that can be used to run the task
   * synchronously.  NOTE: This is not the most efficient way
   * to run the task since job manager tasks are intended to be
   * run asynchronously.
   */
  public JobManagerTask createTask() {
    return new JobManagerTask(jobManager, taskId);
  }

}
TOP

Related Classes of gri.tasks.gui.TaskInfo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.